package com.study.get.jsl;

import cn.hutool.core.util.NumberUtil;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentFontStyle;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * @author zhuzi
 * 2024/6/14 18:6
 */
public interface DataDTO {

    @Data
    @Accessors(chain = true)
    class JslRowCell {
        private String id;
        private KzzDTO cell;
    }

    @Data
    @Accessors(chain = true)
    @ColumnWidth(10)
    @ExcelIgnoreUnannotated
    @EqualsAndHashCode(of = "id")
    class KzzDTO {

        private Long id;

        @ExcelProperty("序号")
        private Integer rn;
        @ExcelProperty("代码")
        private String bondId;
        @ExcelProperty("名称")
        private String bondNm;

        @ContentFontStyle(color = 48)
        @ExcelProperty("价格")
        private BigDecimal price;
        /**
         * 涨幅
         */
        private BigDecimal increaseRt;
        private String stockId;
        private String stockNm;
        /**
         * 股票涨幅
         */
        private BigDecimal sincreaseRt;
        /**
         * 正骨PB
         */
        private BigDecimal pb;
        /**
         * 转股价
         */
        private BigDecimal convertPrice;
        private BigDecimal convertValue;
        //"convert_dt":0,
        /**
         * 转股溢价率
         */
        @ExcelProperty("溢价率")
        private BigDecimal premiumRt;

        /**
         * 债底溢价率
         */
        @ExcelProperty("债底溢价率")
        private BigDecimal bondPremiumRt;
        /**
         * 双低
         */
        @ExcelProperty("双低")
        private BigDecimal dblow;
        //"sw_cd":"220309",
        //"market_cd":"szcy",
        private String btype;
        //"list_dt":"2021-04-20",
        //"owned":0,
        //"hold":0,
        /**
         * 纯债价值
         */
        private BigDecimal bondValue;
        /**
         * 评级
         */
        private String ratingCd;
        /**
         * 正股波动率
         */
        @ExcelProperty("正骨波动")
        private BigDecimal volatilityRate;

        /**
         * 转债占比
         */
        private BigDecimal convertAmtRatio;
        /**
         * 基金持仓
         */
        private BigDecimal fundRt;
        /**
         * 到期时间
         */
        private LocalDate maturityDt;
        /**
         * 剩余年限
         */
        private BigDecimal yearLeft;
        /**
         * 剩余规模
         */
        @ExcelProperty("剩余规模")
        private BigDecimal currIssAmt;
        /**
         * 成交额
         */
        private BigDecimal volume;
        /**
         * 正骨成交额
         */
        private BigDecimal svolume;
        /**
         * 换手率
         */
        private BigDecimal turnoverRt;

        @ApiModelProperty("可转债波动率")
        @ExcelProperty(value = "转债波动率")
        private BigDecimal bondStdevry;


        /**
         * 真实市值
         */
        private BigDecimal currReal;


        public void calcCurrReal() {
            BigDecimal div = NumberUtil.div(currIssAmt, 100);
            this.currReal = NumberUtil.mul(div, price).setScale(3, BigDecimal.ROUND_HALF_UP);
        }

    }

    @Data
    @Accessors(chain = true)
    @ColumnWidth(10)
    @ExcelIgnoreUnannotated
    @EqualsAndHashCode(of = "bondId")
    class KzzBlackListDTO {


        @ExcelProperty("代码")
        private String bondId;
        @ExcelProperty("名称")
        private String bondNm;

        @ContentFontStyle(color = 48)
        @ExcelProperty("价格")
        private BigDecimal price;

        @ExcelProperty("正股代码")
        private String stockId;
        @ExcelProperty("正股名称")
        private String stockNm;
        /**
         * 股票涨幅
         */
        private BigDecimal sincreaseRt;
        /**
         * 正骨PB
         */
        private BigDecimal pb;
        /**
         * 转股价
         */
        private BigDecimal convertPrice;
        @ExcelProperty("转股价值")
        private BigDecimal convertValue;
        //"convert_dt":0,
        /**
         * 转股溢价率
         */
        @ExcelProperty("溢价率")
        private BigDecimal premiumRt;

        /**
         * 债底溢价率
         */
        @ExcelProperty("债底溢价率")
        private BigDecimal bondPremiumRt;
        /**
         * 双低
         */
        @ExcelProperty("双低")
        private BigDecimal dblow;
        //"sw_cd":"220309",
        //"market_cd":"szcy",
        private String btype;
        //"list_dt":"2021-04-20",
        //"owned":0,
        //"hold":0,
        /**
         * 纯债价值
         */
        @ExcelProperty("纯债价值")
        private BigDecimal bondValue;
        /**
         * 评级
         */
        @ExcelProperty("评级")
        private String ratingCd;
        /**
         * 正股波动率
         */
        @ExcelProperty("正骨波动")
        private BigDecimal volatilityRate;

        /**
         * 转债占比
         */
        @ExcelProperty("转债占比")
        private BigDecimal convertAmtRatio;
        /**
         * 基金持仓
         */
        private BigDecimal fundRt;
        /**
         * 到期时间
         */
        @ExcelProperty("到期时间")

        private LocalDate maturityDt;
        /**
         * 剩余年限
         */
        @ExcelProperty("剩余年限")
        private BigDecimal yearLeft;
        /**
         * 剩余规模
         */
        @ExcelProperty("剩余规模")
        private BigDecimal currIssAmt;
        /**
         * 成交额
         */
        private BigDecimal volume;
        /**
         * 正骨成交额
         */
        private BigDecimal svolume;
        /**
         * 换手率
         */
        private BigDecimal turnoverRt;

        @ApiModelProperty("可转债波动率")
        @ExcelProperty(value = "转债波动率")
        private BigDecimal bondStdevry;


        /**
         * 真实市值
         */
        private BigDecimal currReal;


        public void calcCurrReal() {
            BigDecimal div = NumberUtil.div(currIssAmt, 100);
            this.currReal = NumberUtil.mul(div, price).setScale(3, BigDecimal.ROUND_HALF_UP);
        }

    }
}
